package cate.game.pvp.throne.data.ko;

import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;


@NoteClass("王座争霸-淘汰赛-轮次数据")
@Slf4j
public class TBKoRound  {

	@NoteField("轮次")
	public int round;

	@NoteField("对阵分组信息")
	public List<TBKoMatch> matchs;

	public void initialize() {
		if (matchs == null) {
			matchs = new ArrayList<>();
		}
		matchs.forEach(TBKoMatch::initialize);
	}

	public TBKoRound(int round) {
		this.round = round;
	}

	public TBKoRound() {
	}


	public TBKoMatch findMatch(int matchGroup) {
		for (TBKoMatch matchSPO : matchs) {
			if (matchSPO.matchGroup == matchGroup) {
				return matchSPO;
			}
		}
		return null;
	}

	public TBKoMatch findMatch(String roleUid) {
		if (StringUtils.isBlank(roleUid)) {
			return null;
		}
		for (TBKoMatch matchSPO : matchs) {
			if (matchSPO.containRole(roleUid)) {
				return matchSPO;
			}
		}
		return null;
	}
}
